<?

function _app_iface_head_begin ($container) {

	global $_APP_SESSION_USER;

	$company_id = $_APP_SESSION_USER->company_id ? $_APP_SESSION_USER->company_id : "1";

	print <<<HTML
<tr>
	<td class="css_iface_header">
	<img width="170px" height="45px" src="/img/companies/{$company_id}.jpg">


HTML;
}

function _app_iface_head_end ($container) {

	print <<<HTML
	</td>
</tr>
<tr><td class="css_iface_strip"></td></tr>

HTML;
}

function _app_iface_begin ($container) {
	print <<<HTML
<tr>
	<td class="css_iface_main" align="center">

<br>
<table cellpadding="0" cellspacing="0" width="760">
<tr>

HTML;
}

function _app_iface_end ($container) {

	print <<<HTML
</tr>
</table>

	</td>
</tr>
<tr><td class="css_iface_strip"></td></tr>

HTML;
}

function _app_iface_foot_begin ($container) {

	print <<<HTML
<tr>
	<td class="css_iface_footer">


HTML;
}

function _app_iface_foot_end ($container) {

	print <<<HTML
	</td>
</tr>

HTML;
}

function _app_load_iface_begin ($container) {

	global $_APP_SESSION_USER;

	if (isset ($_SESSION["_APP_SESSION"])) {

		$styles = isset ($_REQUEST["theme"]) ? $_REQUEST["theme"] : ($_APP_SESSION_USER->theme ? $_APP_SESSION_USER->theme : "vlaze");
	} else $styles = "vlaze";

	print <<<HTML
<html>
<head>
<link href="/css/{$styles}_site.css" rel="stylesheet" type="text/css"></link>
<script language="JavaScript" src="/js/jquery-latest.js"></script>
<script language="JavaScript" src="/js/common.js"></script>
</head>
<body>
<center>
<table class="css_main_iface" cellpadding="0" cellspacing="0">

HTML;
}

function _app_load_iface_end ($container) {

	print <<<HTML
</table>
</center>
</body>
</html>
HTML;
}

function _app_create_iface_panel ($title, $style) {

	$_OBJECT_IFACE_PANEL = new Container ();
	$_OBJECT_IFACE_PANEL->set_callback_begin ("_app_iface_panel_begin");
	$_OBJECT_IFACE_PANEL->set_callback_end ("_app_iface_panel_end");
	$_OBJECT_IFACE_PANEL->set_variable ("title", $title);
	$_OBJECT_IFACE_PANEL->set_variable ("style", $style);

	return $_OBJECT_IFACE_PANEL;
}

function _app_iface_panel_begin ($container) {

	print <<<HTML
<div class="css_{$container->get_variable ("style")}_outer">
	<div class="css_{$container->get_variable ("style")}_header">{$container->get_variable ("title")}</div>
	<div class="css_inner_object">


HTML;
}

function _app_iface_panel_end ($container) {

	print <<<HTML
	</div>
	<div class="css_{$container->get_variable ("style")}_inner">&nbsp;</div>
</div>
<br>

HTML;
}

function _app_select_query ($params, $columns) {

	global $_GLOBAL_DBH;
	$query = $_GLOBAL_DBH->query ($params);
	$result = array ();

	while ($row = $_GLOBAL_DBH->fetch_object ($query)) {

		array_push ($result, array (
				$columns["key"]=>$row->$columns["key"],
				$columns["value"]=>$row->$columns["value"]));
	}

	return $result;
}

function _app_session_login ($container) {

	print <<<HTML
<form action="/index.php" method="post">
<tr>
	<td class="css_site_login" align="left" valign="top">
		<div class="css_site_access">User ID: <input class="css_fieldset_input" type="input" value="{$_REQUEST["user_name"]}" size="10" name="user_name"></div>
		<div class="css_site_access">Password: <input class="css_fieldset_input" type="password" value="{$_REQUEST["user_password"]}" size="10" name="user_password"></div>
		<div class="css_site_access"><input class="css_fieldset_input" type="submit" value="Log-In"></div>
		<a class="css_site_access_link" href="new_account.php">&gt; Create An Account</a>&nbsp;:::&nbsp;<a class="css_site_access_link" href="get_password.php">&gt;Forgot My Password</a>

	</td>
</tr>
</form>
<tr><td class="css_iface_strip"></td></tr>

HTML;
}

function _app_session_logout ($container) {

	print <<<HTML
<tr>
	<td class="css_site_login" align="right" valign="top">
		{$_SESSION["_APP_SESSION_USER"]->first}&nbsp;{$_SESSION["_APP_SESSION_USER"]->last} with {$_SESSION["_APP_SESSION_USER"]->realm} Rights&nbsp;<a class="css_site_access_link" href="/index.php?session_logout=true">&gt; Log-Out</a>

	</td>
</tr>
<tr><td class="css_iface_strip"></td></tr>

HTML;
}

?>
